﻿/*********************************************************************************/
//CLICK
/*********************************************************************************/
var nrc_message="";
function clickIE(){if(document.all){(nrc_message);return false;}}
function clickNS(e){if(document.layers||(document.getElementById&&!document.all)){if(e.which==2||e.which==3){(nrc_message);return false;}}}if(document.layers){document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}document.oncontextmenu=new Function("return false")
/*********************************************************************************/

//VENTANA SIN MENU DEL NAVEGADOR
/*********************************************************************************/
/*
var OrigenPage = "http://localhost/WebApplication1/WebForm1.aspx";
function openWinSCxC(){window.open(location, 'Pfizer','status=yes,menubar=no,scrollbars=yes,resizable=yes');}
if((typeof window.opener) == 'undefined') 
{
 openWinSCxC();
 location = OrigenPage;
}
*/
//VENTANAS MODALES
/*********************************************************************************/

function setFocus(ObjID)
{
document.getElementById(ObjID).focus();
}

function goBack()
{
window.history.go(-1);
return false;
}

function cleanField(ObjID)
{
document.getElementById(ObjID).value = '';
}

function openDialog(url, ancho, alto, resize) {
var _left = (screen.width) ? (screen.width-ancho)/2 : 100;
var _top = (screen.height) ? ((screen.height-alto)/2)-30 : 100;
window.open(url,'pagina'+ancho,'width=' + ancho + ', height=' + alto + ',scrollbars=1,resizable=' + resize + ',status=1,left=' + _left + ',top=' + _top + '');

}

//PINNED
/*********************************************************************************/
var _pinned = true;
    
    function toggleDockPanel(){
	
	var thePanelInfo = document.getElementById('InfoPanelBar');
	var theImage = document.getElementById('theDockPanelImage');

	if (_pinned){
		thePanelInfo.style.display = 'none';
		theImage.src='../App_Themes/Sony_Silver/Images/SPLIT_PIN_DOWN.gif';
		theImage.alt='Click para mostrar';
	}else{
	
		thePanelInfo.style.display = '';
		theImage.src='../App_Themes/Sony_Silver/Images/SPLIT_PIN_UP.gif';
		theImage.alt='Click para ocultar';
	}
	_pinned = !_pinned;
}
/*********************************************************************************/



/*********************************************************************************/
    


//SOLO NUMEROS
/*********************************************************************************/

function acceptNum(eve)
{
  var key = eve.keyCode||eve.charCode;
    var caract = String.fromCharCode(key);
   
    var myRe= /^[0-9.,+-]+$/;
    if ((myRe.test(caract)))
        return true;
    
    
            switch (key)
            {
            case 32:
                if (caract!=' ')
                {
                    return true;
                }
            break;
            
            case 8:
                return true;
            break;

            case 46:
                if (caract!='.')
                {
                    return true;
                }
            break;

            case 27:
                return true;
            break;

            case 9:
                return true;
            break;

            case 37:
                if (caract!='%')
                {
                    return true;
                }
            break;

            case 39:
                if (caract!="'")
                {
                    return true;
                }
            break;

            }


    return false;
}



//function acceptNumA(evt,value){var key=sn_nav?evt.which:evt.keyCode;var flag, flag2=false;(value.indexOf('.')== -1)?flag=true:flag=false;if(!flag){((value.length - value.indexOf('.')) > 2)?flag2=true:flag2=false;}return((key<=13)||(key>=48&&key<=57&&!flag2)||(key==46&&flag))}



function acceptNumA(evt,value)
{
var key=sn_nav?evt.which:evt.keyCode;
var flag, flag2=false;
(value.indexOf('.')== -1)?flag=true:flag=false;
if(!flag)
{
((value.length - value.indexOf('.')) > 2)?flag2=false:flag2=false;
}
return((key<=13)||(key>=48&&key<=57&&!flag2)||(key==46&&flag))

}




function onlytext(evt){var key=sn_nav?evt.which:evt.keyCode;return(key<=13||(key>=65&&key<=90)||(key>=97&&key<=122));}
function nosig(evt){var key=sn_nav?evt.which:evt.keyCode;return !(key==37);}
function validar(e) {return !(e.keyCode==86 && e.ctrlKey)}




function formatCurrency(num) {

num = num.toString().replace(/\$|\,/g,'');

if(isNaN(num))
num = "0";
sign = (num == (num = Math.abs(num)));
num = Math.floor(num*100+0.50000000001);
cents = num%100;
num = Math.floor(num/100).toString();
if(cents<10)
cents = "0" + cents;
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4*i+3))+','+
num.substring(num.length-(4*i+3));
return (((sign)?'':'-') + num + '.' + cents);
}


function DesformatCurrency(num)
{/*
if(!isNaN(num))
{*/
num = num.toString().replace(/\$|\,/g,'');
/*
}
else
{
num = '';
}*/

return num;
}



function acceptNumAN(evt,value, Obj)
{
var key=sn_nav?evt.which:evt.keyCode;
var flag,flag2=false;
(value.indexOf('.')== -1)?flag=true:flag=false;
    if(!flag)
    {
        ((value.length - value.indexOf('.')) > 2)?flag2=false:flag2=false;
    }
    if (key==45)
    {
        if(Obj.value.indexOf('-')== -1)
            Obj.value = '-' +  Obj.value;
        else 
            Obj.value = Obj.value.substr(1,Obj.value.length);
    return false;
    }
return((key<=13)||(key>=48&&key<=57&&!flag2)||(key==46&&flag))
}


 // funcion vantenaSecundaria
  function ventanaSecundaria(url){    
 
   // alert('El total del canje supera los puntos acumulados');
      window.open(url,"Buscar Tienda","width=120,height=300,scrollbars=NO");
    
 } 


function GenerateLogin()
        {
            var sLogin="";
            var partLogin="";
            partLogin = document.getElementById('DetailsView1_txt_name').value
            sLogin = partLogin.charAt(0) + document.getElementById('DetailsView1_txt_surname').value;
            return sLogin
   
        }
        
function Validate_Login(control)
{
    try
    {
        document.getElementById(control).value = document.getElementById(control).value.replace(new RegExp ("[^A-Za-z0-9-_]", "gi"), '');           
    }
    catch(ex){
    }
    
}

//SOLO LETRAS Y NUMEROS
//Valida los caracteres a ingresar en el TextBox del GridView
//Agregado por Marino Fourtounis -- 03/07/2008
/*********************************************************************************/
 function ValCaract_txtexh_commentary(eve)
{
////    var key = event.keyCode||event.charCode;
////    var caract = String.fromCharCode(key);
////   
////    var myRe= /^[A-Za-z0-9-.,:;"?¿]+$/;
////    if (!(myRe.test(caract)))
////        window.event.keyCode=0;
////      text.value = text.value.replace(new RegExp ("[^A-Za-z0-9-.,:;\"?¿]", "gi"), '');   
//    var key = eve.keyCode||eve.charCode;
//    var caract = String.fromCharCode(key);
//  
// //   var myRe= /^[A-Za-z0-9-.,:;$%/_?¿"\"]+$/;
//    if ((myRe.test(caract)))
//        return true;
//         switch (key)
//            {
//            case 32:
//                if (caract!=' ')
//                {
//                    return true;
//                }
//            break;
//            
//            case 8:
//                return true;
//            break;
//            case 46:
//                if (caract!='.')
//                {
//                    return true;
//                }
//            break;

//            case 27:
//                return true;
//            break;

//            case 9:
//                return true;
//            break;

//            case 37:
//                if (caract!='%')
//                {
//                    return true;
//                }
//            break;

//            case 39:
//                if (caract!="'")
//                {
//                    return true;
//                }
//            break;

//            }

//    return false;
}

//SOLO NUMEROS
//Valida los caracteres a ingresar en el TextBox del GridView
//Agregado por Sandra Sarda -- 24/10/2008
/*********************************************************************************/
 function ValNumero(eve)
{
    var key = eve.keyCode||eve.charCode;
    var caract = String.fromCharCode(key);
 
    var myRe= /^[0-9,]+$/;
    if ((myRe.test(caract)))
    {
        return true;
    }else
    {
        return false;
    }
}

//CEDULA
//Valida los caracteres a ingresar en el TextBox del GridView
//Agregado por Edgar Teixeira -- 06/03/2009
/*********************************************************************************/
 function ValCedula(eve)
{
    var key = eve.keyCode||eve.charCode;
    var caract = String.fromCharCode(key);  
   if(eve.srcElement.value.length==0){
   
   var myRe= /^[VvPpEe]$/;
   
   if ((myRe.test(caract)))
    {
        return true;
    }else
    {
        return false;
    }
    
   }
   else{
   
   var myRe= /^\d$/;
    if ((myRe.test(caract)))
    {
        return true;
    }else
    {
        return false;
    }
   
   }
    
}
//Rif
//Valida los caracteres a ingresar en el TextBox del GridView
//Agregado por Ruben Besteiro -- 06/04/2009
/*********************************************************************************/
 function ValRif(eve)
{
     var key = eve.keyCode||eve.charCode;
    var caract = String.fromCharCode(key);  
   if(eve.srcElement.value.length==0){
   
   var myRe= /^[VvPpEe]$/;
   
   if ((myRe.test(caract)))
    {
        return true;
    }else
    {
        return false;
    }
    
   }
   else{
   
   var myRe= /^\d$/;
    if ((myRe.test(caract)))
    {
        return true;
    }else
    {
        return false;
    }
   
   }
    
}

//SOLO Nombre.
//Valida los caracteres a ingresar en el TextBox del GridView
//Agregado por Ruben Besteiro -- 06/5/2009
/*********************************************************************************/
 function ValTexto(eve)
{
    var key = eve.keyCode||eve.charCode;
    var caract = String.fromCharCode(key);
   
    var myRe= /^[A-ZñÑa-z ]+$/
    if ((myRe.test(caract)))
    {
        return true;
    }else
    {
        return false;
    }
}

//SOLO Email @ _ - .
//Valida los caracteres a ingresar en el TextBox del GridView
//Agregado por Ruben Besteiro -- 06/5/2009
/*********************************************************************************/
 function ValEmail(eve)
{
    var key = eve.keyCode||eve.charCode;
    var caract = String.fromCharCode(key);
   var myRe= /^[A-Z@-_.ñÑa-z0-9]+$/
    
    if ((myRe.test(caract)))
    {
        return true;
    }else
    {
        return false;
    }
}
//SOLO Nombre y caracters '@ ; , .
//Valida los caracteres a ingresar en el TextBox del GridView
//Agregado por Ruben Besteiro -- 06/5/2009
/*********************************************************************************/
 function ValNombreUsuario(eve)
{
    var key = eve.keyCode||eve.charCode;
    var caract = String.fromCharCode(key);
   var myRe= /^[A-Z@';:.ñÑa-z0-9- -]+$/
    
    if ((myRe.test(caract)))
    {
        return true;
    }else
    {
        return false;
    }
}



//SOLO LETRAS 
//Valida los caracteres a ingresar en el TextBox del GridView
//Agregado por Sandra Sarda -- 24/10/2008
/*********************************************************************************/
 function ValLetras(eve)
{
    var key = eve.keyCode||eve.charCode;
    var caract = String.fromCharCode(key);
   
    var myRe= /^[A-ZñÑa-z]+$/
    if ((myRe.test(caract)))
    {
        return true;
    }else
    {
        return false;
    }
}

//SOLO NOMBRES 
//Valida los caracteres a ingresar en el TextBox del GridView
//Agregado por Ruben Besteiro -- 01/04/2009
/*********************************************************************************/
 function ValNombre(eve)
{
    var key = eve.keyCode||eve.charCode;
    var caract = String.fromCharCode(key);
   var myRe= /^[A-ZñÑa-z0-9 ]+$/

    if ((myRe.test(caract)))
    {
        return true;
    }else
    {
        return false;
    }
}
//SOLO FECHA
//Valida los caracteres a ingresar en el TextBox del GridView
//Agregado por Sandra Sarda -- 24/10/2008
/*********************************************************************************/
 function ValFecha(eve)
{
    var key = eve.keyCode||eve.charCode;
    var caract = String.fromCharCode(key);
   
    var myRe= /^[0-9-/]+$/;
    if ((myRe.test(caract)))
    {
        return true;
    }else
    {
        return false;
    }
}


//SOLO Bloqueo de control v y control c 
//Valida que no se precione la tecla control v y control c
//Agregado por Ruben  Besteiro-- 03/04/2009
/*********************************************************************************/


  function noCTRL(e) {
        var code = (document.all) ? event.keyCode : e.which;
        var ctrl = (document.all) ? event.ctrlKey : e.modifiers & Event.CONTROL_MASK;
        var msg = "Esta Operacion Se Encuentra Bloqueada";
        if (document.all) {
            if (ctrl && code == 86) //CTRL+V
            {
                alert(msg);
                window.event.returnValue = false;
            }
            else if (ctrl && code == 67) //CTRL+C 
            {
                alert(msg);
                window.event.returnValue = false;
            }
        }
        else {
            if (ctrl == 2) //CTRL letra
            {
                alert(msg);
                return false;
            }
        }
    } 
    function inhabilitar() {
        alert("Esta función está inhabilitada.")
        return false
    }

    document.oncontextmenu = inhabilitar 


//SOLO MODELOS
//Valida los caracteres a ingresar en el TextBox del GridView
//Agregado por Sandra Sarda -- 24/10/2008
/*********************************************************************************/
 function ValModelo(eve)
{
    var key = eve.keyCode||eve.charCode;
    var caract = String.fromCharCode(key);
   
    var myRe= /^[A-ZñÑa-z0-9- ]+$/
    if ((myRe.test(caract)))
    {
        return true;
    }else
    {
        return false;
    }
}

function ValCaract_txt_Ajuste_Puntos(text)
{    
   text.value = text.value.replace(new RegExp ("[^0-9_]", "gi"), '');   
}

function ValCaract_txt_Letras(text)
{    
   text.value = text.value.replace(new RegExp ("[^A-ZñÑa-z0-9 ]", "gi"), '');   
}

function ValCadena(eve)
{
    var key = eve.keyCode||eve.charCode;
    var caract = String.fromCharCode(key);
   
   if(eve.srcElement.value.length==0)
   {
        return false;    
   }
   else{

        return true;
   
   }
    
}
function ValLogin(eve)
{
    var key = eve.keyCode||eve.charCode;
    var caract = String.fromCharCode(key);
   var myRe= /^[A-Za-z-_.@Ññ0-9]+$/
    
    if ((myRe.test(caract)))
    {
        return true;
    }else
    {
        return false;
    }
}